package Proxy;

import javax.swing.*;
import java.awt.*;

public class WuYuanSpecialty {
    public static void main(String[] args) {
        SGProxy sgProxy = new SGProxy();
        sgProxy.display();
    }
}
interface Specialty{
    void display();
}
class WuYuanSp extends JFrame implements Specialty{
    private static final long serialVersionUID = 1L;
    public WuYuanSp(){
        super("代理模式测试");
        this.setLayout(new GridLayout(1,1));
        JLabel l1=new JLabel(new ImageIcon("src/Proxy/WuyuanSpecialty.jpg"));
        this.add(l1);
        this.pack();
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    @Override
    public void display() {
        this.setVisible(true);
    }
}
//代理
class SGProxy implements Specialty{
    private WuYuanSp realSp = new WuYuanSp();
    @Override
    public void display() {
        preRequest();
        realSp.display();
        postRequest();
    }
    public void preRequest(){
        System.out.println("真实类加载前预处理");
    }
    public void postRequest(){
        System.out.println("加载后的处理");
    }
}
